package com.eudon.genius.api.core.utils;

import java.util.Optional;
import java.util.function.Consumer;

/**
 * Optional工具类
 *
 * @author eudon
 * @since 2025/9/25
 */
public class OptionalUtil {
    private OptionalUtil() {
    }

    public static <T> void getOrElse(T value, Consumer<? super T> consumer, Runnable runnable) {
        Optional<T> optional = Optional.ofNullable(value);
        if (optional.isPresent()) {
            optional.ifPresent(consumer);
        } else {
            runnable.run();
        }
    }
}
